﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Yunwei.Domain.Models
{
    public partial class User
    {
        [Required]
        public int Id { get; set; }

        [Required(ErrorMessage = "必填")]
        [StringLength(20, MinimumLength = 4, ErrorMessage = "{2}到{1}个字符")]
        [Display(Name = "用户名")]
        public string Name { get; set; }

        [StringLength(20, MinimumLength = 2, ErrorMessage = "{2}到{1}个字符")]
        [Display(Name = "昵称")]
        public string NickName { get; set; }

        [StringLength(20, MinimumLength = 2, ErrorMessage = "{2}到{1}个字符")]
        [Display(Name = "真实姓名")]
        public string RealName { get; set; }

        [Display(Name = "性别")]
        public short Sex { get; set; }

        [Required(ErrorMessage = "必填")]
        [Display(Name = "邮箱")]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }

        [Required(ErrorMessage = "必填")]
        [Display(Name = "密码")]
        public string Password { get; set; }

        [Required(ErrorMessage = "必填")]
        [StringLength(20, MinimumLength = 8, ErrorMessage = "{2}到{1}个字符")]
        public string Phone { get; set; }

        [Display(Name = "头像")]
        [StringLength(200, MinimumLength = 5, ErrorMessage = "{2}到{1}个字符")]
        public string Avatar { get; set; }

        [Display(Name = "帐号状态")]
        public short Status { get; set; }

        [Display(Name = "注册时间")]
        public System.DateTime RegistTime { get; set; }

        [Display(Name = "登陆时间")]
        public Nullable<System.DateTime> LoginTime { get; set; }

        [Display(Name = "登陆IP")]
        public string LoginIP { get; set; }

        [Display(Name = "VIP等级")]
        public short VIPLevel { get; set; }

        [Display(Name="角色")]
        public string Role { get; set; }

        [Display(Name = "VIP")]
        [NotMapped]
        public string VIP
        {
            get
            {
                switch (VIPLevel)
                {
                    case 1:
                        return "普通会员";
                    case 2:
                        return "金牌会员";
                    case 3:
                        return "钻石会员";
                }

                return "普通会员";
            }
        }
    }
}
